import { Statistic } from "@/model/HomeModels"
import axios from "axios"

export const loadStatisticAPI = async (type: string):
    Promise< Statistic | null > => {
         console.log(`API加载资源类型为 ${type} 的统计数据...`)
    try {
        // 发送搜索资源请求
        const response = await axios.post('/api/home/getStatistic', 
            type,
            { headers: { 'Content-Type': 'application/json' } }
        )
        console.log("后端返回的数据：", response.data)              //调试
        return response.data
    } catch (error) {
        // 搜索资源失败，捕获异常
        console.error('获取资源数据失败:', error)
        return null 
    }
}